From ca8c67629a509f45e83ebdb0f679b692707ad7d9 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 28 Feb 2018 14:02:41 +0000 Subject: [PATCH] xen/domain: Added debug safety in the domain_create() failure path Hitting the fail path with err = 0 causes callers to dereference a NULL pointer, as 0 fails an IS_ERR() check. All of the paths appear to be fine, but leave some logic to help catch stray misuses. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- xen/common/domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index 3cefe765a2..219a3e325e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -399,6 +399,9 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, return d; fail: + ASSERT(err < 0); /* Sanity check paths leading here. */ + err = err ?: -EILSEQ; /* Release build safety. */ + d->is_dying = DOMDYING_dead; if ( hardware_domain == d ) hardware_domain = old_hwdom; -- 2.30.2